<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<title>Initialization Data Methods</title>
	</head>
	<body>
		<h1>Initialization Data Methods</h1>

		<p>
		It is often convenient if data methods can assume that all variables of a data class have been initialized.
		This can be achieved by calling an initialization data method directly after creating a new instance of the data class. 
		To enforce that such an initialization method is called, the initialization data methods should be annotated with "@Init".
		</p>
		<p>
		A data class can have multiple initialization methods, but only one of these methods has to be called. 
		If a data class has no methods with this annotation, no initialization method has to be called.
		The "@Init" annotation is not inherited by subclasses.
		</p>
		

		<h3>Example</h3>
<pre>
<b><span style="color:DarkRed">data class</span></b> Addition
<b><span style="color:DarkRed">variables</span></b>
	requiredInt : Integer
<b><span style="color:DarkRed">methods</span></b>
	@Init
	initAtZero() : Integer
		requiredInt := 0;
		return requiredInt
			
	@Init
	initAt(i : Integer) : Integer
		requiredInt := i;
		return requiredInt
		
	add(i : Integer) : Integer
		requiredInt := requiredInt + i;
		return requiredInt


<b><span style="color:DarkRed">process class</span></b> SomeClass()
<b><span style="color:DarkRed">ports
messages
variables
init</span></b>
	someMethod()()
<b><span style="color:DarkRed">methods</span></b>
	someMethod()() | a : Addition |
		a := new(Addition) initAtZero()
</pre>

	</body>
</html>